@extends("layouts.backend.webadmin")
@section('page-header')
<h1>
    <small>config</small>
</h1>
@endsection

@section('content')
<!-- Main content -->
<section class="content">
    <input type="hidden" name="tid" value="{{$tid}}">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-body">
                    <table id="ck-list" class="table table-bordered table-striped">
                        <thead>
                        <tr>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
@stop
@section('javascript-end')
<script src="{{env('APP_ROOT')}}/js/common.js"></script>
    <script>
    $(function () {
        console.log('welcome to ck page.')
        $(function () {
            console.log('welcome to pm page.');
            var m1 = manage();
            var tables = $('#ck-list').DataTable({
                //调整结构
                "dom": '<"dataTables_filter">rtip',
                "autoWidth":true,
                //国际化
                'oLanguage'   :{
                    'sUrl'    : '{{env("APP_ROOT")}}/assets/bootstrap/js/zh_cn.json'
                },
                "initComplete": function( settings, json ) {
                    var button = '<a href="{{route('admin.checkoption.addpage')}}" class="btn btn-primary checkoption-add" style="float: left;"><i class="fa fa-plus-square" aria-hidden="true">增加</i></a>';
                    $('.dataTables_filter').html(button);
                    var _$this = this;

                    m1.filter(jQuery,'',_$this,false);
                },
                "paging": true, // 禁止分页
                "bSort": false,//禁止排序
                "processing": true,
                //开启服务器模式
                serverSide: true,
                ajax: {
                    //指定数据源
                    url: "{{route('admin.checkoption.search')}}?tid="+$('input[name="tid"]').val(),
                    type: "GET",
                    data: function(d){
                        delete d.columns;
                        return d;
                    },
                    //接受服务器数据
                    dataSrc:function(json){
                        getToken();
                        return json.data;
                    }
                },
                pageLength: {{  $pageNum }},
                //data值对应数据库字段名
                columns: [
                    {
                        'title':'编号',
                        "data": "id"
                    },
                    {
                        'title':'测试项',
                        "data": "name",
                        "render": function(data,type,row,meta) {
                            var tid = $('input[name="tid"]').val();
                            var ckid = row['id'];
                            return '<a href="{{route('admin.checkoption.vuls')}}?tid='+tid+'&ckid='+ckid+'">'+data+'</a>'

                        }
                    },
                    {
                        'title':'数量',
                        'data':"vuls_num"
                    },
                    {
                        "title":"操作",
                        "targets": -2,
                        "data": null,
                        "width":'8%',
                        "render": function(data,type,row,meta){
                            var strBtn = '';
                            if (row['opt_type'] == 1){
                                strBtn += '<a href="{{route('qyapp.editpage')}}?id='+"{{$appId}}"+'" class="btn btn-primary qyapp-index" type="button">修改</a>';
                            }else{

                                strBtn += '<a href="{{ URL::route('admin.flaw.vulsadd') }}?app_id='+"{{$appId}}"+'&check_id='+row['id']+'" class="btn btn-primary checkoption-projectvuls" type="button">提交</a>';
                            }
                            return strBtn;
                        }
                    }],
                //所有列过滤xss
                columnDefs: [{
                    "targets": "_all",
                    "render": $.fn.dataTable.render.text()
                }]
            });
        });
    });
</script>
@endsection
